import request from '@/utils/request'
import {encodeParams} from '@/utils'
import Const from '@/utils/config'

//获取标签列表  0: 合同标签 1：服务标签
export function getAllLabel(labelType) {
  return request({
    url: `/api/label/all?labelType=${labelType}`,
    method: 'GET',
  })
}

//新增标签列表
export function addLabel(data) {
  return request({
    url: `/api/label`,
    method: 'POST',
    data
  })
}

//编辑标签
export function updateLabel(id) {
  return request({
    url: `/api/label/${id}`,
    method: 'PUT',
  })
}

//删除标签
export function deleteLabel(id) {
  return request({
    url: `/api/label/${id}`,
    method: 'DELETE',
  })
}


//根据ParentCode查询区域
export function findByParentCode(parentCode) {
  return request({
    url: `/api/area/findByParentCode`,
    method: 'GET',
    params:{parentCode:parentCode}
  })
}



// 前端获取系统时间
export function getSysTime() {
  return request({
    url: `/api/area/getSysTime`,
    method: 'GET',
  })
}

// 前端保存数据
export function saveData(data) {
  return request({
    url: "/api/param/save",
    method: 'POST',
    data
  })
}
// 前端获取自用数据
export function getData(paramKey) {
  return request({
    url: `/api/param/findByParamKey/${paramKey}`,
    method: 'GET',
  })
}

//获取上传图片token
export function getUploadImgAccess(fileName) {
  return request({
    url: `/api/qiniu/certification?fileName=${fileName}`,
    method: 'GET',

  })
}

export function getUploadVideoAccess(data) {
  return request({
    url: '/api/file/getVideoUploadToken',
    method: 'POST',
    data
  })
}

//获取视频播放凭证
export function getVideoPlayUrl(fileUrl) {
  return request({
    url: `/api/file/getVideoPlayUrl`,
    method: 'POST',
    data:{fileUrl}
  })
}

//全站枚举值
export function getSysParams(data) {
  return request({
    url: '/api/dict/getSysParams',
    method: 'GET',
    params: data
  })
}



//获取小程序二维码
export function getWxappCode(appType,page,busType,paramMap,width=100) {
  const appId = Const.APPID_FilTER[appType]
  return request({
    url: '/api/user/qrCode/applet/create',
    method: 'POST',
    data:{
      appId,
      page,
      width,
      auto_color: true,
      is_hyaline: true,
      line_color: {},
      paramMap,
      busType,
    }
  })
}



//地址反编译经纬度
export function getJWCode(keywords) {
  return request({
    url: `/gdapi/place/text?key=9e72f91a2b78b55731cb6ac8638c4128&keywords=${keywords}`,
    method: 'GET',
  })
}




